package com.zfzs.post.controller;

import com.zfzs.post.aop.log.Log;
import com.zfzs.post.common.bean.ResponseResult;
import com.zfzs.post.model.dto.DisTerminalAgentDTO;
import com.zfzs.post.modules.post.domain.dto.QueryTerminalDistribuDTO;
import com.zfzs.post.model.vo.DistribuVO;
import com.zfzs.post.service.DistributionSerivce;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @author wq
 * @date 2019/10/9 14:12
 * @description
 */
@RestController
@RequestMapping("distribution/")
@Slf4j
public class DistributionController {

    @Autowired
    private DistributionSerivce distributionSerivce;

    /**
     * 获取个人机器
     * @param queryTerminalDistribuDTO
     * @return
     */
    @PostMapping("get_owner_terminal")
    @Log("获取个人机器")
    public ResponseResult getOwnerTerminal(@RequestBody QueryTerminalDistribuDTO queryTerminalDistribuDTO){
        List<DistribuVO> list=distributionSerivce.getOwnerTerminal(queryTerminalDistribuDTO);
        return ResponseResult.ok(new HashMap<String,Object>(){{put("list",list);put("count",list.size());}});
    }

    /**
     * 分配机器
     * @param disTerminalAgentDTO
     * @return
     */
    @PostMapping("dis_terminal_agent")
    @Log("分配机器")
    public ResponseResult disTerminal2Agent(@RequestBody DisTerminalAgentDTO disTerminalAgentDTO){
        distributionSerivce.disTerminal2Agent(disTerminalAgentDTO);
        return ResponseResult.okMsg("分配成功");
    }


}
